package com.maserb.monitor.remote;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.poi.util.ArrayUtil;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class SchoolRecordResponseEntity {
    /**
     * 学生卡是否有效 0无效，1有效
     */
    private Integer validFlag;

    public byte[] getBytes() {
        byte[] flagData = MessageByteUtils.fromString(validFlag.toString(), 1);

        byte[][] datas = new byte[][]{flagData};
        int totalLength = 0;
        for (int i = 0; i < datas.length; i++) {
            totalLength += datas[i].length;
        }
        byte[] result = new byte[totalLength];
        int index = 0;
        for (int i = 0; i < datas.length; i++) {
            ArrayUtil.arraycopy(datas[i], 0, result, index, datas[i].length);
            index += datas[i].length;
        }

        return result;
    }
}
